<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>粘性定位</title>
    <style>
        h1 {
            position: sticky;
            top: 0;
        }
        h3 {
            position: sticky;
            top: 0;
        }

        .box {
            border: 2px solid #000;
            margin: 20px;
            height: 400px;
            background: #ccc;
        }

        .box2 {
            border: 2px solid #000;
            margin: 10px;
            height: fit-content;
        }
    </style>
</head>

<body>
    <div class="box">
        <h1>我是粘性布局所以当我的上一级被带走的时候，虽然我想粘在网页上但是不行呢</h1>

    </div>

    <div>
        <div>
        </div>
        <p>Romeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
            sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
            asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
            sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
            asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
            sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
            asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
            sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
            asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
            sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
            asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
            sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
            asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
            sadsaRomeo asdd sadsaRomeo asdd sadsa </p>
    </div>

    <h1>但是我 就不一样了 哈哈 我的父级是body所以没人可以带走我 哈哈哈</h1>

    <p>222 Romeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
        sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
        asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
        sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
        asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
        sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
        asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
        sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
        asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
        sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
        asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
        sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo
        asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd sadsaRomeo asdd
        sadsaRomeo asdd sadsaRomeo asdd sadsa </p>

    <div class="box2">
        <h3>我们这些小杂鱼虽然也想黏住顶部但是我们的父组件不行啊没高度一下就被带走了 哎 ！！！</h3>
    </div>
    <div class="box2">
        <h3>我们这些小杂鱼虽然也想黏住顶部但是我们的父组件不行啊没高度一下就被带走了 哎 ！！！</h3>
    </div>
    <div class="box2">
        <h3>我们这些小杂鱼虽然也想黏住顶部但是我们的父组件不行啊没高度一下就被带走了 哎 ！！！</h3>
    </div>
    <div class="box2">
        <h3>我们这些小杂鱼虽然也想黏住顶部但是我们的父组件不行啊没高度一下就被带走了 哎 ！！！</h3>
    </div>
    <div class="box2">
        <h3>我们这些小杂鱼虽然也想黏住顶部但是我们的父组件不行啊没高度一下就被带走了 哎 ！！！</h3>
    </div>
    <div class="box2">
        <h3>我们这些小杂鱼虽然也想黏住顶部但是我们的父组件不行啊没高度一下就被带走了 哎 ！！！</h3>
    </div>
    <div class="box2">
        <h3>我们这些小杂鱼虽然也想黏住顶部但是我们的父组件不行啊没高度一下就被带走了 哎 ！！！</h3>
    </div>


    <div style="height: 1600px;"></div>
</body>
<style>

</style>

</html>